<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ef="http://www.enginframe.com/2000/EnginFrame"
                xmlns:efx="xalan://com.enginframe.xslt.xalan.Extensions"
                extension-element-prefixes="efx"
                exclude-result-prefixes="ef efx">

<!--
 * Copyright 1998-2009 by Nice, srl.,
 * Via Serra 33, Camerano Casasco, Asti, 14020, Italy
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Nice, srl. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Nice.
-->

<!--
 * layout-templates.xsl
 * Contains generic EnginFrame portal layout templates
-->


  <xsl:output
    encoding="iso-8859-1"
    method="html"
    media-type="text/html"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"
    omit-xml-declaration="yes"
  />


  <xsl:variable name="LOGGED_USER" select="//ef:profile/ef:login-name/."/>
  <xsl:variable name="EFHELP" select="//ef:session-list/ef:session[@id='EFHELP']" />
  <xsl:variable name="IRODS_ZONE" select="//ef:session-list/ef:session[@id='irodsZone']"/>
  <xsl:variable name="IRODS_RES" select="//ef:session-list/ef:session[@id='irodsDefResource']"/>
  <xsl:variable name="IRODS_SERVER" select="//ef:session-list/ef:session[@id='irodsHost']"/>
  <xsl:variable name="IRODS_PORT" select="//ef:session-list/ef:session[@id='irodsPort']"/>
  <xsl:variable name="my_resource" select="//ef:session-list/ef:session[@id='my_resource']"/>

  <!-- header rendering -->
  <xsl:template name="header_rendering">
    <title>
      <xsl:value-of select="$agent_name"/>
    </title>

    <xsl:call-template name="head_rendering"/>

    <!-- Jquery -->
    <script src="/{$_root_context}/lib/js/jquery.js" type="text/javascript"></script>
    <script src="{$js}/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
    <script src="{$js}/jquery.autocomplete.pack.js" type="text/javascript"></script>
    <script src="{$js}/jquery.dataTables.min.js" type="text/javascript"></script>
    <script src="{$js}/dropdown.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(document).ready(function() {
      var my_res='<xsl:value-of select="$my_resource"/>';
      var tokens = my_res.split(":");
      var output = "";
      for (i = 0; i &lt; tokens.length; i++) {
        output += "&lt;li&gt;&lt;a href=\"irods.xml?_uri=//com.enginframe.irods/irods.change.res&amp;irods_res="+tokens[i]+"\"&gt;"+tokens[i]+"&lt;/a&gt;&lt;/li&gt;";
      }
      $("#irodsRes").html(output);
    });
    </script>

    <xsl:comment>[if lte IE 6]&gt;
      &lt;link type="text/css" rel="StyleSheet" href="../../admin/css/iepatch.css" /&gt;
      &lt;![endif]</xsl:comment>
    <xsl:comment>[if IE 7]&gt;
      &lt;link type="text/css" rel="StyleSheet" href="../../admin/css/ie7patch.css" /&gt;
      &lt;![endif]</xsl:comment>
    <link rel="shortcut icon" href="{$img}/ef_favicon.gif" />
    <link type="text/css" rel="StyleSheet" href="{$css}/smoothness/jquery-ui-1.7.2.custom.css" />
    <link type="text/css" rel="StyleSheet" href="{$css}/jquery.autocomplete.css" />
    <link type="text/css" rel="StyleSheet" href="{$css}/tables.css" />

    <link type="text/css" rel="StyleSheet" href="{$css}/filemanager.css" />
    <link type="text/css" rel="StyleSheet" href="{$css}/layout.css" />
  </xsl:template>



  <!-- banner rendering -->
  <xsl:template name="banner_rendering">
    <div id="banner">
      <ul>
        <li class="banner-level-1">
          <a href="/{$_root_context}/demo/" title="EnginFrame logo" />
        </li>
        <li id="tofill"></li>
        <li class="banner-level-2">
          <form action="{$agent}.xml?_uri=//{$agent}/login" method="post" name="loginform" id="ef_loginform">
            <div id="logintable"><ul>
              <xsl:choose>
                <xsl:when test="$LOGGED_USER != ''">
                  <ul  id="jsddm" title="Click to choose the Default Resource"  >

                   <li id="welcome2" >
                     <xsl:value-of select="$LOGGED_USER"/>
                   </li>
                   <xsl:if test="$IRODS_SERVER != ''">
                     <li id="hostname" >
                       <xsl:value-of select="$IRODS_SERVER"/>:<xsl:value-of select="$IRODS_PORT"/>
                     </li>
                   </xsl:if>
                   <xsl:if test="$IRODS_ZONE != ''"> 
                     <li id="zone"> 
                       <xsl:value-of select="$IRODS_ZONE"/>
                     </li>
                   </xsl:if>
                   <xsl:choose>
                      <xsl:when test="$IRODS_RES != ''">
                        <li id="res">
                          <xsl:value-of select="$IRODS_RES"/>
                           <ul id="irodsRes">
                           </ul>
                        </li>
                      </xsl:when>
                      <xsl:otherwise>
                        <li id="res">
                          <nobr><b>Click Here</b> to choose the Default Resources</nobr>
                           <ul id="irodsRes">
                           </ul>
                        </li>
                      </xsl:otherwise>
                    </xsl:choose>
                  </ul>

                </xsl:when>
                <xsl:otherwise>
                  <li id="externallinks1">
                    <div id="moreinfo1">
                      More&#160;info&#160;on:
                    </div>
                  </li>
                  <li id="externallinks2">
                    <div id="linkslist">
                      <ul>
                        <li id="moreinfo2">                        
                          <a id="nicelink" href="http://www.nice-software.com">NICE</a>
                        </li>                  
                        <li id="moreinfo3">
                          <a id="nicelink" href="http://www.enginframe.com">EnginFrame</a>
                        </li>                  
                        <li id="moreinfo4">
                          <a id="nicelink" href="http://www.enginframe.com/demo">Online&#160;demo</a>                         
                        </li>                   
                      </ul>
                    </div>
                  </li>                 
                </xsl:otherwise>
              </xsl:choose>
            </ul></div>
            <div class="clear"> </div>
          </form>
        </li>
      </ul>
    </div>
  </xsl:template>

  <!-- topmenu rendering -->
  <xsl:template name="topmenu_rendering">
    <div id="topmenu">
        <div id="topmenu-level-1">
          <a id="topmenu-a1" href="/{$_root_context}/demo/standard/">
            <p class="topmenu-level-b">Tutorial Home</p>
          </a>
        </div>
        <div id="topmenu-level-2">
          <a id="topmenu-a2" href="/{$_root_context}/demo/new/demo.new.xml">
            <p class="topmenu-level-b">New in EnginFrame 5.0</p>
          </a>
        </div>
<!--        <div id="topmenu-level-4">
          <a id="topmenu-a4" href="{$agent}.xml?_uri=//com.enginframe.system/list.spoolers">
            <p class="topmenu-level-b">My data<xsl:call-template name="ef_help">
                <xsl:with-param name="help-href">list-spooler.html</xsl:with-param>
              </xsl:call-template>
            </p>
          </a>
        </div>
-->       
         <div id="topmenu-level-4">
          <a id="topmenu-a5" href="{$agent}.xml?_uri=//com.enginframe.irods/irods.rspooler">
            <p class="topmenu-level-b">My data</p>
          </a>
        </div>
<!--
        <div id="topmenu-level-4">
          <a id="topmenu-a5" href="{$agent}.xml?_service=files">
            <p class="topmenu-level-b">My data (new)</p>
          </a>
        </div>
-->
        <div id="topmenu-level-4">
          <a id="topmenu-a5" href="{$agent}.xml?_uri=//irods/my.files">
            <p class="topmenu-level-b">My data (new)</p>
          </a>
        </div>
<!--        <div id="topmenu-level-6">
          <a id="topmenu-a6" href="{$agent}.xml?_uri=//com.enginframe.{$grid}/job.list.all">
            All jobs</a><xsl:call-template name="ef_help">
              <xsl:with-param name="help-href">job-list.html</xsl:with-param>
            </xsl:call-template>       
        </div>
-->
        <div id="topmenu-level-7">
          <a id="topmenu-a7" href="{$agent}.xml?_service=auth">
            <p class="topmenu-level-b">New Zone</p>
          </a>
        </div>
        <div id="topmenu-level-11">
          <a id="topmenu-a11" href="{$agent}.xml?_uri=//com.enginframe.system/logout">
            <img src="{$img}/shim.gif" width="39" height="40" border="0" alt="Logout" title="Logout" />
          </a>
        </div>
        <div id="topmenu-level-9">

          <xsl:choose>
            <xsl:when test="$EFHELP">
              <a id="topmenu-a9" href="{$agent}.xml?_uri=//com.enginframe.system/help.disable">
                <img src="{$img}/shim.gif" width="39" height="40" border="0" alt="Online Help" title="Disable Online Help" />
              </a>
            </xsl:when>
            <xsl:otherwise>
              <a id="topmenu-a9" href="{$agent}.xml?_uri=//com.enginframe.help/enable&amp;EF_HELP_LANG=en_EN">
                <img src="{$img}/shim.gif" width="39" height="40" border="0" alt="Online Help" title="Enable Online Help" />
              </a>           
            </xsl:otherwise>
          </xsl:choose>

        </div>
        <!--div id="topmenu-level-8">
          <a id="topmenu-a8" href="{$agent}.xml?_uri=//com.enginframe.rss/feeds">
            <img src="{$img}/shim.gif" width="39" height="40" border="0" alt="RSS Feeds" title="RSS Feeds" />
          </a>
        </div-->     
        <efx:acl>
          <ef:apply-acl select="admin-only">
            <div id="topmenu-level-12">
              <a id="topmenu-a12" href="/{$_root_context}/admin">
                <img src="{$img}/shim.gif" width="39" height="40" border="0" alt="RSS Feeds" title="Administration portal" />
              </a>
            </div>
          </ef:apply-acl>
        </efx:acl>
    </div>
  </xsl:template>

  <xsl:template match="ef:show-spooler" mode="show-spooler-actions" priority="+10">
    <xsl:if test="$streaming_download = 1">
      <script type="text/javascript" src="/{$_root_context}/lib/js/com.enginframe.stream.js">
        <xsl:comment> // </xsl:comment>
      </script>
    </xsl:if>
  </xsl:template>

  <!-- contents rendering -->
  <xsl:template name="contents_rendering">
    <div id="contents">
      <table id="contenttable">
        <tr id="contenttr">
          <td id="navigationtd">            
            <div id="navigationdiv">
              <xsl:call-template name="navigation_rendering"/>
            </div>
          </td>
          <td id="contenttd">
            <div id="contentdiv">
              <xsl:call-template name="content_rendering"/>        
            </div>
          </td>
        </tr>
      </table>
    </div>
  </xsl:template>

  <!-- footer rendering -->
  <xsl:template name="footer_rendering">
    <div id="footer">
      <ul>
        <li class="footer-level-1">
          Copyright &#169; 1998 - 2009 <a href="http://www.nice-software.com">NICE</a> s.r.l.<br/>
          All trademarks and logos on this page are owned by NICE s.r.l. or by their respective owners.
        </li>
      </ul>
    </div>
  </xsl:template>
  
  <!-- ef:service system template override -->
  <xsl:template match="ef:service" priority="100">
    <xsl:param name="update"/>

    <xsl:apply-templates select="ef:name|ef:version"/>

    <xsl:variable name="uses-upload" select="boolean(descendant::ef:option[@type = 'file'])"/>
    <xsl:variable name="action-url-fragment">
      <xsl:text>//</xsl:text>
      <xsl:value-of select="$agent"/>
      <xsl:text>/</xsl:text>
      <xsl:value-of select="@id"/>
      <xsl:if test="$EF_CHARSET"><xsl:text>&amp;EF_CHARSET=</xsl:text><xsl:value-of select="$EF_CHARSET"/></xsl:if>
    </xsl:variable>
    <xsl:variable name="action-url">
      <xsl:call-template name="create_url">
        <xsl:with-param name="url_fragment"><xsl:value-of select="$action-url-fragment"/></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>

    <xsl:element name="form">
      <xsl:attribute name="id"><xsl:value-of select="$serviceform_id"/></xsl:attribute>
      <xsl:attribute name="name"><xsl:value-of select="$portletNamespace"/>serviceform</xsl:attribute>
      <xsl:attribute name="method">post</xsl:attribute>
      <xsl:attribute name="action"><xsl:value-of select="$action-url"/></xsl:attribute>
      <xsl:attribute name="onsubmit">return submitEFAction(this, '<xsl:value-of select="$portletNamespace"/>UploadApplet');</xsl:attribute>
      <xsl:attribute name="enctype">application/x-www-form-urlencoded</xsl:attribute>
      <xsl:if test="$uses-upload">
        <xsl:attribute name="enctype">multipart/form-data</xsl:attribute>
      </xsl:if>
      <xsl:variable name="isDTreeEnabled"><xsl:call-template name="is_dtree_enabled"/></xsl:variable>
      <xsl:if test="$isDTreeEnabled = 'false'">
        <input type="hidden" name="_folder" value="{$_folder}" />
      </xsl:if>

      <xsl:apply-templates select="table|a|div|fieldset|legend"><xsl:with-param name="update" select="$update"/></xsl:apply-templates>

      <xsl:apply-templates select="descendant::script[not(name(parent::node())='ef:info')]" />

      <xsl:if test="count(ef:option|ef:info) &gt; 0">
        <table style="border-width: 0px; width: 100%">
          <xsl:apply-templates select="ef:info[position()=1]" mode="default"/>
          <tr>
            <td>
              <xsl:choose>
                <xsl:when test="count(ef:option) &gt; 0">
                  <table style="border-width: 0px">
                    <xsl:apply-templates select="ef:option|ef:info[position()>1]" mode="default">
                      <xsl:with-param name="update"><xsl:value-of select="$update"/></xsl:with-param>
                    </xsl:apply-templates>
                    <xsl:if test="count(descendant::ef:option[@type='mfu' or @type='sfu']) &gt; 0">
                      <tr>
                        <td>
                          <input type="hidden" id="{$reuse_spooler_id}" name="EF_REUSE_SPOOLER" value="" />
                        </td>
                      </tr>
                    </xsl:if>
                  </table>
                </xsl:when>
                <xsl:when test="ef:info[position() &gt; 1]">
                  <table style="border-width: 0px;">
                    <xsl:apply-templates select="ef:info[position()>1]" mode="default" />
                  </table>
                </xsl:when>
                <xsl:otherwise>&#160;</xsl:otherwise>
              </xsl:choose>
            </td>
          </tr>
        </table>
      </xsl:if>

      <xsl:apply-templates select="ef:output-option" />

      <xsl:apply-templates select="ef:action" />

    </xsl:element>
  </xsl:template>
  
  
</xsl:stylesheet>
